import java.io.*;

//写数据转为字符流
public class Demo12 {
    public static void main(String[] args) {
        try(OutputStream outputStream = new FileOutputStream("C:/测开/test.txt")) {
            //这就相当于把字节流转成字符流了
            PrintWriter writer = new PrintWriter(outputStream);
            writer.printf("hello");
            // 刷新缓冲区，确保数据写入文件
            writer.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
